package com.sisyphus.mock.data;

import com.sisyphus.mock.data.entities.UserPostFavoriteEntity;

import java.util.List;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;

@Dao
public interface UserPostFavoriteMapper {

    @Insert
    void insert(UserPostFavoriteEntity entity);

    @Delete
    void delete(UserPostFavoriteEntity entity);

    @Query("SELECT * FROM user_post_favorite WHERE uid = :uid ORDER BY create_date DESC LIMIT :limit OFFSET (:offset - 1) * :limit")
    List<UserPostFavoriteEntity> findByUserId(Long uid, int offset, int limit);

    @Query("SELECT * FROM user_post_favorite WHERE post_id = :postId LIMIT 1")
    UserPostFavoriteEntity findByPostId(Long postId);

}
